# -*- encoding: utf-8 -*-

"""
6.4.1 分组
"""

import pandas as pd

data = {
    '日期': ['2020-03-11','2020-03-11','2020-03-11','2020-03-11','2020-03-11',
            '2020-03-12','2020-03-12','2020-03-12','2020-03-12','2020-03-12',
            '2020-03-13','2020-03-13','2020-03-13','2020-03-13','2020-03-13'],
    '代码': ['000625.SZ','000762.SZ','600132.SH','600009.SH','000882.SZ',
            '000625.SZ','000762.SZ','600132.SH','600009.SH','000882.SZ',
            '000625.SZ','000762.SZ','600132.SH','600009.SH','000882.SZ'],
    '成交额': [422.08,73.65,207.04,510.59,63.28,
            471.78,59.2,156.82,853.83,52.84,
            789.1,57.01,223.06,1196.14,56.32],
    '成交量': [37091400,9315300,4127800,7233100,28911100,
            42471700,7724200,3143100,12350400,24828900,
            68771048,7741802,4496598,17662768,27484360]
}

vo = pd.DataFrame(data)

for name, df in vo.groupby('日期'):
    print('组名：%s'%name)
    print('-------------------------------------------')
    print(df)
    print()
    
for name, df in vo.groupby('代码'):
    print('组名：%s'%name)
    print('-------------------------------------------')
    print(df)
    print()
